package com.jk.controller;

import com.jk.entity.AreaEntity;
import com.jk.entity.ClothEntity;
import com.jk.entity.UserEntity;
import com.jk.service.EsServcie;
import com.jk.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 类描述：
 *
 * @ClassName ClothController
 * @Description TODO
 * @Author fandasen
 * @Date 2022/5/30 17:52
 * @Version 1.0
 */
@RestController
@RequestMapping("user")
public class ClothController {
    @Autowired
    private UserService userService;
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 登录
     * @param user
     * @param
     * @retur
     */
    @RequestMapping(value = "login")
    public String login(UserEntity user){
        return userService.login(user);
    }



    /**
     * 注册三级联动
     * @param pid
     * @return
     */
    @RequestMapping(value = "getprovince")
    public List<AreaEntity> getprovince(Integer pid){
        return userService.getprovince(pid);
    }



    /**
     * 发送验证码
     * @param phone
     * @return
     */
    @RequestMapping(value = "gainCode")
    public String gainCode(String phone){
        return userService.gainCode(phone);
    }

    /**
     * 手机号注册
     * @param
     * @return
     */
    @RequestMapping(value = "phoneRegister")
    public String phoneRegister(UserEntity user){
        return userService.phoneRegister(user);
    }

    /**
     * 注册
     * @param
     * @return
     */
    @RequestMapping(value = "register")
    public String register(UserEntity user){
        return userService.register(user);
    }

    @Autowired
    private EsServcie esServcie;

    /**
     * @Author fandasen
     * @Description //TODO es搜索
     * @Date 11:19 2022/6/14
     * @Param [name]
     * @return java.util.List<com.jk.entity.ClothEntity>
     **/
    @RequestMapping("queryShop")
    public List<ClothEntity>  ellist(String name){
        return esServcie.ellist(name);
    }
}
